<template>
  <div>
    <table-where :forms="forms"></table-where>
    <wms-table ref="tableQuery" :tableDatas="tableDatas" @detailClick="close"></wms-table>
  </div>
</template>

<script setup name="查找往来单位">
import { ref, reactive } from 'vue'
const emit = defineEmits(['close'])
const tableQuery = ref()
const close = (row)=>{
  emit('close',row)
}
const onSubmit = () => {
  tableQuery.value.getData().then(()=>{
    if(tableDatas.tableData.length === 1){
      close(tableDatas.tableData[0]);
    }
  })
}
const forms = reactive({
  data: {},
  compValue: [
    { label: '', value: 'params', type: 'iconinput',placeholder:"名称/编号" ,onclick:()=>{
      onSubmit()
    }},
    { label: '查询', type: 'button', onclick: onSubmit }
  ]
})
const tableDatas = reactive({
  body: {
    head: 'clients',
    url: '/Information/getClientsPage',
    params: forms.data,
    type: 'POSTJSON'
  },
})

const open = (paramValue)=>{
  tableDatas.body.params.params = paramValue;
  onSubmit();
}

defineExpose({ open })
</script>
